<template>
  <view class="container">
    <!-- 顶部组件 -->
    <u-navbar
      :is-back="true"
      :background="{ background: '#fff' }"
      :border-bottom="false"
      id="nav-bar"
      title="申请记录"
    ></u-navbar>
    <u-tabs
      :list="tabList"
      :is-scroll="false"
      :current="tabCurrent"
      @change="change"
    ></u-tabs>
    <!-- 订单列表 -->
    <!-- <mescroll-body
        ref="mescrollRef"
        @init="mescrollInit"
        top="0"
        @down="downCallback"
        :up="upOption"
        @up="upCallback"
      > -->

    <view class="list">
      <view class="item">
        <view class="header">
          <image
            class="icon"
            src="/static/images/icon-zzsq.png"
            mode="widthFix"
          ></image>
          <text class="title">自主申请</text>
          <text class="status blue">审核通过</text>
        </view>
        <view class="time">2024-26-07 14:32:21</view>
        <view class="num">+0</view>
      </view>
    </view>
    <!-- </mescroll-body> -->
  </view>
</template>
<script>
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js';
import service from '@/common/service';
import util from '@/common/utils';

export default {
  mixins: [MescrollMixin],
  data() {
    return {
      upOption: {
        page: {
          num: 0,
          size: 10,
        },
        noMoreSize: 5,
        empty: {
          icon: 'https://api.hjsfpay.com/image/newimg/all-noData.png',
          tip: '',
        },
      },
      mescroll: null,
      tabList: [
        {
          name: '全部状态',
          count: 0,
        },
        {
          name: '待提交',
          count: 0,
        },
        {
          name: '待审核',
          count: 0,
        },
        {
          name: '审核通过',
          count: 0,
        },
        {
          name: '已还款',
          count: 0,
        },
        {
          name: '审核拒绝',
          count: 0,
        },
      ],
      tabCurrent: 0,
      currentData: {},
    };
  },
  onLoad(e) {
    if (e.tab) {
      this.tabCurrent = Number(e.tab);
    }
  },
  methods: {
    customBack() {
      uni.switchTab({
        url: '/pages/my/index',
      });
    },
    mescrollInit(mescroll) {
      this.mescroll = mescroll;
    },
    downCallback() {
      this.recordList = [];
      this.mescroll.resetUpScroll();
    },
    upCallback(page) {
      this.getTradePage(page);
    },
    getTradePage(page) {
      const that = this;
      const param = {
        pageNumber: page.num,
        pageSize: page.size,
        status: that.tabCurrent,
      };
      service.getTradePage(
        param,
        function (res) {
          if (res && res.data) {
            that.mescroll.endSuccess(res.data.data.length);
            if (page.num == 1) that.recordList = [];
            that.recordList = that.recordList.concat(res.data.data);
          }
        },
        function (res) {}
      );
    },
    change(index) {
      this.tabCurrent = index;
      this.recordList = [];
      this.mescroll.resetUpScroll();
    },
  },
};
</script>

<style lang="scss" scoped>
page {
  background-color: #f5f5f5;
}

.container {
  width: 100%;
  min-height: 100vh;
  padding: 0;
  text-align: center;
  background-color: #f5f5f5;
}

.list {
  width: 100%;
  padding: 30rpx;
  .item {
    position: relative;
    width: 100%;
    height: auto;
    padding: 30rpx;
    background: #ffffff;
    border-radius: 16rpx;
    .header {
      display: flex;
      align-items: center;
      width: 100%;
      .icon {
        width: 32rpx;
        height: 32rpx;
      }
      .title {
        margin-left: 10rpx;
        font-family: PingFang SC, sans-serif;
        font-weight: 800;
        font-size: 28rpx;
        color: #333333;
      }
      .status {
        margin-left: 10rpx;
        height: 28rpx;
        line-height: 28rpx;
        padding: 0 18rpx;
        font-family: PingFang SC, sans-serif;
        font-weight: 400;
        font-size: 20rpx;
        border-radius: 14rpx;
      }

      .blue {
        color: #3388ff;
        background: #e5f0ff;
      }

      .red {
        color: #fa6161;
        background: #ffe5e5;
      }

      .purple {
        color: #6d5acb;
        background: #eae5ff;
      }

      .green {
        color: #22c071;
        background: #d5f5e5;
      }

      .yellow {
        color: #ffbb33;
        background: #fff6e5;
      }
    }
    .time {
      margin-top: 24rpx;
      width: 100%;
      font-family: PingFang SC, sans-serif;
      font-weight: 400;
      font-size: 24rpx;
      color: #999999;
      text-align: left;
    }
    .num {
      position: absolute;
      top: 50%;
      right: 30rpx;
      transform: translateY(-50%);
      font-family: PingFang SC, sans-serif;
      font-weight: 800;
      font-size: 28rpx;
      color: #f03434;
    }
  }
}
</style>
